package selectClass;

import lombok.Data;
import org.springframework.security.crypto.password.PasswordEncoder;
import selectClass.User;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

@Data
public class RegistrationForm {
    private String username;
    private String password;

    @NotBlank
    @Size(min = 2, message = "Name must be at least 2 characters long")
    private String fullname;
    private String userGrade;
    private String userMajor;
    private String userCollege;

    public User toUser(PasswordEncoder passwordEncoder) {
        return new User(
                username, passwordEncoder.encode(password),
                fullname, userGrade, userMajor, userCollege);
    }

}
